#ifndef _H_PALTFORM
#define _H_PALTFORM

#include "stm32l1xx.h"
#include "stm32l1xx_gpio.h"
#include "type.h"

#define GPIO_HIGH(a,b) 		a->BSRRL = b
#define GPIO_LOW(a,b)		a->BSRRH = b
#define GPIO_TOGGLE(a,b) 	a->ODR ^= b 

#define DELAY_1_CLK    delay_loop(2) //asm("nop"); //delay_loop(1) /*the function use 3 cpu clk for each iteration, thus 2*3 @ 8 MHz clk = 6 */
#define DELAY_9_CLK    delay_loop(3) //delay_loop(18) //
#define DELAY_36_CLK   delay_loop(12) //delay_loop(72) //
#define DELAY_50_US    delay_loop(123) //delay_loop(720) //
#define DELAY_10_US    delay_loop(25) //delay_loop(144) //

static __inline__ void delay_loop(volatile UINT16 __count)
{
    while((__count--)>0);
}

void delay_ms(volatile uint32_t delay);

#endif